package com.st.mall.product.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.st.mall.product.mapper.IImgMapper;
import com.st.mall.product.model.ImgModel;
import com.st.mall.product.service.IImgService;

@Service
public class ImgServiceImpl implements IImgService {
	
	@Autowired
	private IImgMapper mapper;

	@Override
	public int insert(ImgModel imgModel) {
		// TODO Auto-generated method stub
		return mapper.insert(imgModel);
	}

	@Override
	public ImgModel selectId(String code) {
		// TODO Auto-generated method stub
		return mapper.selectId(code);
	}

	@Override
	public List<ImgModel> selectAll(ImgModel imgModel) {
		// TODO Auto-generated method stub
		return mapper.selectAll(imgModel);
	}

	@Override
	public int delete(String url) {
		// TODO Auto-generated method stub
		return mapper.delete(url);
	}
	
	@Override
	public int setMain(ImgModel imgModel) {
		setOutMain(imgModel);
		return mapper.setMain(imgModel);
	}

	@Override
	public int setOutMain(ImgModel imgModel) {
		// TODO Auto-generated method stub
		return mapper.setOutMain(imgModel);
	}
	@Override
	public int selectCount(ImgModel imgModel) {
		String code = imgModel.getCode();
		imgModel.setCode(code == null ? "%%" : "%" + code + "%");
		String url = imgModel.getUrl();
		imgModel.setUrl(url == null ? "%%" : "%" + url + "%");
		return mapper.selectCount(imgModel);
	}

}
